package com.caird.pmp.iot.message.impl;

import com.caird.pmp.iot.message.MessageBase;
import io.netty.buffer.ByteBuf;
import lombok.Data;


@Data
public class DeviceMessage0900 extends MessageBase {

    public DeviceMessage0900() {
        id = (short)0x8900;
    }

    @Override
    public int getMaxBodyLength() {
        return 1000;
    }

    @Override
    public boolean decodeBody(ByteBuf raw) {
        if (getBodyLength() < 2)
            return false;

        //透传类型
        type = raw.readByte();

        //透传数据
        byte[] bs = new byte[getBodyLength() - 1];
        raw.readBytes(bs);
        data = new String(bs);

        return true;
    }

    //透传类型
    private byte type;

    //透传数据
    private String data;
}
